package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicWorkshopDAO;
import com.cssy.xxkj.basic.entity.BasicWorkshopDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-11
 */
public class BasicWorkshopDAOImpl extends SqlMapClientDaoSupport implements BasicWorkshopDAO {

    /**
     * 插入数据
     * @param basicWorkshopDO
     * @return 插入数据的主键
     */
    public String insertBasicWorkshopDO(BasicWorkshopDO basicWorkshopDO) {
        Object id = getSqlMapClientTemplate().insert("BasicWorkshop.insert", basicWorkshopDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicWorkshopDO
     * @return 查出的记录数
     */
    public Integer countBasicWorkshopDOByExample(BasicWorkshopDO basicWorkshopDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicWorkshop.countByDOExample", basicWorkshopDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicWorkshopDO
     * @return 受影响的行数
     */
    public Integer updateBasicWorkshopDO(BasicWorkshopDO basicWorkshopDO) {
        int result = getSqlMapClientTemplate().update("BasicWorkshop.update", basicWorkshopDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicWorkshopDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicWorkshopDO> findListByExample(BasicWorkshopDO basicWorkshopDO) {
        List<BasicWorkshopDO> list = getSqlMapClientTemplate().queryForList("BasicWorkshop.findListByDO", basicWorkshopDO);
        return list;
    }

    /**
     * 根据主键获取basicWorkshopDO
     * @param id
     * @return basicWorkshopDO
     */
    public BasicWorkshopDO findBasicWorkshopDOByPrimaryKey(String id) {
        BasicWorkshopDO basicWorkshopDO = (BasicWorkshopDO) getSqlMapClientTemplate().queryForObject("BasicWorkshop.findByPrimaryKey", id);
        return basicWorkshopDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicWorkshopDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicWorkshop.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicWorkshopDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicWorkshopDO> list = getSqlMapClientTemplate().queryForList("BasicWorkshop_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicWorkshop_ex.count", scs);
        return rows;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicWorkshop_ex.deleteBizRemoved", id);
        return rows;
	}

}